#include <iostream>
#include <boost/program_options.hpp>
#include <string>
#include <vector>
#include <math.h>
#include "get_arg.h"


// link with -lboost_filesystem-gcc -lboost_program_options-gcc
// program_options_helper.cpp

#define DEBUG_LEVEL 6
#include <debug_func.h>



// my functions
#include <open_stream_name_with_subscript.h>
#include <print_error.h>
#include <program_options_helper.h>

using std::string;
using std::cerr;
using namespace program_options_helper;
namespace po = boost::program_options_lg;

//_______________________________________________________________________________________

//		process_command_line_options

//				from command line
//				Created [9/13/2001]

//_______________________________________________________________________________________
bool process_command_line_options(int argc, char* argv[], t_program_args& args)
{

//	po::options_description mandatory_args("Mandatory Arguments");
	args.optional_args.add_options()
	("orphans,o", po::value<string>(&args.file_orphans)
										->set_name("PATH")
										->default_value("[SPECIES].orphans"),
									"PATH to output the list of genes with no close orthologues.")
	("macro_synteny_histogram,M", po::value<string>(&args.file_macro_synteny_histogram)
										->set_name("PATH")
										->default_value("macro.[SPECIES].histogram"),
									"PATH to output the macro synteny block sizes.")
	("micro_synteny_histogram,m", po::value<string>(&args.file_micro_synteny_histogram)
										->set_name("PATH")
										->default_value("micro.[SPECIES].histogram"),
									"PATH to output the micro synteny block sizes.")
	("list_micro_synteny,l", po::value<string>(&args.file_micro_synteny)
										->set_name("PATH")
										->default_value("micro.[SPECIES].list"),
									"PATH to output the which genes are in which micro synteny block.")
	("list_macro_synteny,L", po::value<string>(&args.file_macro_synteny)
										->set_name("PATH")
										->default_value("macro.[SPECIES].list"),
									"PATH to output the which genes are in which micro synteny block.")
	("chromosome_macro_histogram,c", po::value<string>(&args.file_chromosome_macro)
										->set_name("PATH")
										->default_value("macro_per_chromosome.[SPECIES].histogram"),
									"PATH to output the macro synteny blocks per chromosome.")
	("full_macro_synteny,F", po::value<string>(&args.file_full_macro_synteny)
										->set_name("PATH")
										->default_value("full.[SPECIES].macro.synteny"),
									"PATH to output the all the synteny block breakdown.")
	("full_micro_synteny,f", po::value<string>(&args.file_full_micro_synteny)
										->set_name("PATH")
										->default_value("full.[SPECIES].micro.synteny"),
									"PATH to output the all the synteny block breakdown.")
	("remove_singletons,r", po::bool_switch(&args.remove_singletons),
									"Remove singletons before building synteny.");
	

//	args.optional_args.add_options()
//	("header,H",					"Add a header line (matrix name prefixed with '>') "
//									"to the matrix output.");

	args.add_std_options();
	po::options_description all_args("");
	all_args
//				.add(mandatory_args)
				.add(args.optional_args);

	// parse command line
	po::variables_map vm;
	po::store(po::command_line_parser(argc, argv).options(all_args).run(), vm);
	po::notify(vm);



	if (vm.count("version"))
	{
		print_version(cerr, *argv, "1.0");
		return false;
	}
	if (vm.count("help"))
	{
		string exe_description =
				"Takes tab delimited values of species, chromosome, ortholog_id, "
				"gene_position, strand and gene_id from STDIN "
				"and joins together adjacent orthologs in syntenic blocks.\n"
				"The path options should include the string \"[SPECIES]\" "
				"which will be substituted to the actual species names.";
		print_usage(cerr, string(*argv), "[OPTIONS] < DATA > ANALYSIS",
							all_args, exe_description, 80);
		return false;
	}
//	check_required_options(vm, mandatory_args);

	args.header		= vm.count("header");



	args.open_err_log();
	return true;
}








